package game.module.hall.processor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.common.PlayingRoleMsgProcessor;
import game.entity.PlayingRole;
import game.module.ddz.logic.DdzDataManager;
import game.module.hall.dao.OnlineCountCache;
import game.module.mj.logic.MjDataManager;
import game.module.nn.logic.NnDataManager;
import game.module.sss.logic.SssDataManager;
import lion.common.MsgCodeAnn;
import lion.netty4.message.MyRequestMessage;
import lion.netty4.message.RequestMessageRaw;
import lion.netty4.message.RequestProtoMessage;
import lua.LuaMessageHall.C2SQueryOnlineCount;
import lua.LuaMessageHall.S2CQueryOnlineCount;

@MsgCodeAnn(msgcode = C2SQueryOnlineCount.id, accessLimit = 500)
public class QueryOnlineCountProcessor extends PlayingRoleMsgProcessor {

	private static Logger logger = LoggerFactory.getLogger(QueryOnlineCountProcessor.class);

	@Override
	public void process(PlayingRole hero, RequestMessageRaw request) throws Exception {
		int playerId = hero.getId();
		logger.info("query online count,playerId={}", playerId);
		// ret
		S2CQueryOnlineCount respMsg = new S2CQueryOnlineCount();
		respMsg.module_id = new byte[] { 1, 2, 3, 4 };
		respMsg.online_count = new int[] { DdzDataManager.getInstance().getOnlineSize(), NnDataManager.getInstance().getOnlineSize(),
				SssDataManager.getInstance().getOnlineSize(), MjDataManager.getInstance().getOnlineSize() };
		OnlineCountCache.getInstance().respSetPlayerOnlineCount(respMsg.online_count);
		hero.writeAndFlush(respMsg.build(hero.alloc()));
	}

	@Override
	public void processProto(PlayingRole playingRole, RequestProtoMessage request) throws Exception {
		// null
	}

	@Override
	public void processWebsocket(PlayingRole playingRole, MyRequestMessage request) throws Exception {
		// null
	}

}
